from django.http import HttpResponse
from django.shortcuts import render
from django.views import View
# 生成验证码第三方包,直接将 captcha 包复制到项目 libs 目录下
from libs.captcha.captcha import captcha
from django_redis import get_redis_connection
# Create your views here.
class ImageCodeView(View):
    def get(self,request,uuid):
        text,image = captcha.generate_captcha()
        # 将验证码保存到setting里 Redis  2号库
        redis_cli = get_redis_connection('code')
        redis_cli.setex(uuid,100,text)
        return HttpResponse(image,content_type = 'image/jpg')





